#include "HeatRadiationMaterial.h"
#include "libmesh/system.h"
#include "libmesh/radial_basis_interpolation.h"
#include "libmesh/quadrature.h"
#include <iostream>

registerMooseObject("RoshanApp", HeatRadiationMaterial);

template<>
InputParameters validParams<HeatRadiationMaterial>()
{
	InputParameters params = validParams<Material>();
	params.addRequiredCoupledVar("temperature", "Coupled Temperature");
	params.addRequiredParam<Real>("qc", "qc");
	params.addRequiredParam<Real>("tw0", "tw0");
	params.addRequiredParam<Real>("surface_emissivity", "surface emissivity");
	return params;
}

HeatRadiationMaterial::HeatRadiationMaterial(const InputParameters & parameters) :
	Material(parameters),
	_convection_flux(declareProperty<Real>("convection_heat_flux")),
	_convection_flux_jacobi(declareProperty<Real>("convection_heat_flux_jacobi")),
	_temperature(coupledValue("temperature")),
	_qc(getParam<Real>("qc")),
	_tw0(getParam<Real>("tw0")),
	_epsilon(getParam<Real>("surface_emissivity"))
{
}

void HeatRadiationMaterial::computeProperties()
{
	Real sigma = 5.67e-8;

	for(_qp = 0; _qp < _qrule->n_points(); ++_qp)
	{
		Real tw = _temperature[_qp];
		Real tw4 = Utility::pow<4>(tw);
		Real tw3 = Utility::pow<3>(tw);
		_convection_flux[_qp] = _qc - _epsilon * sigma * tw4;
		_convection_flux_jacobi[_qp] = - 4 * _epsilon * sigma * tw3;
	}
}
